//大数据中的三个接口
$.ajax({
	async: true, //同步，异步
	url: "http://218.60.150.112:8080/8890/api/interface/search/getBjAvgDays.shtml", //请求的服务端地址
	data: {},
	type: "get",
	dataType: "json",
	success: function(data) {
		var banjie = $("#banjie");
		var banjieVal = $("#banjieVal");
		var html = "";
		var html2 = "";
		for (var key in data) {
			html2 += '<span>' + key + '</span>';
			html += '<span>' + data.办结平均天数 + '</span> ';

		}
		banjie.append(html2)
		banjieVal.append(html);
	},
	error: function(XMLHttpRequest, textStatus, errorThrown) {
		console.log("图表请求数据失败!");
	},
});
$.ajax({
	async: true, //同步，异步
	url: "http://218.60.150.112:8080/8890/api/interface/search/showAllBlYw.shtml", //请求的服务端地址
	data: {},
	type: "get",
	dataType: "json",
	success: function(data) {

		var zongbanli = $("#zongbanli");
		var zongbanliVal = $("#zongbanliVal");
		var html3 = "";
		var html4 = "";
		for (var key in data) {
			html3 += '<span>' + key + '</span>';
			html4 += '<span>' + data.总体办理量 + '</span> ';


		}
		zongbanli.append(html3)
		zongbanliVal.append(html4);
	},
	error: function(XMLHttpRequest, textStatus, errorThrown) {
		console.log("图表请求数据失败!");
	},

});
$.ajax({
	async: true, //同步，异步
	url: "http://218.60.150.112:8080/8890/api/interface/search/showAllBjYw.shtml", //请求的服务端地址
	data: {},
	type: "get",
	dataType: "json",
	success: function(data) {

		var zongbanjie = $("#zongbanjie");
		var zongbanjieVal = $("#zongbanjieVal")
		var html5 = "";
		var html6 = "";
		for (var key in data) {
			html5 += '<span>' + key + '</span>';
			html6 += '<span>' + data.总体办结量 + '</span> ';


		}
		zongbanjie.append(html5)
		zongbanjieVal.append(html6);
	},
	error: function(XMLHttpRequest, textStatus, errorThrown) {
		console.log("图表请求数据失败!");
	},

});

//第一个
var dataChen = []; //类别数组
var dataValue = []; //数据数组
$.ajax({
	type: "post",
	async: true, //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
	url: "http://218.60.150.112:8080/8890/api/interface/search/showAllBjYwByDs.shtml", //请求的服务端地址
	data: {},
	dataType: "json", //返回数据形式为json
	success: function(data) {
		//请求成功时执行该函数内容，result即为服务器返回的json对象
		if (data) {
			var firstNo1 = data.各地市办结量;
			for (var i = 0; i < firstNo1.length; i++) {
				for (var j = 0; j < firstNo1[i].length - 1; j++) {
					dataChen.push(
						firstNo1[i][j]
					)
					dataValue.push(
						firstNo1[i][j + 1]
					)
				}

			}


			var myChart1 = echarts.init(document.getElementById('main1'));
			//			console.log(1)
			myChart1.setOption({
				color: ['#3398DB'],
				tooltip: {
					trigger: 'axis',
					axisPointer: { // 坐标轴指示器，坐标轴触发有效
						type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
					}
				},

				dataZoom: [{
						show: true,
						start: 80,
						end: 70
					},
					{
						type: 'inside',
						start: 80,
						end: 70
					}
				],

				grid: {
					top: 30,
					bottom: 60
				},

				xAxis: {

					type: 'category',
					data: dataChen,
					axisTick: {
						alignWithLabel: true
					},
					axisLabel: { //轴标
						show: true,
						interval: '0',
						textStyle: {
							lineHeight: 5,
							padding: [2, 2, 0, 2],
							height: 50,
							fontSize: 12,
							color: '#fff',
						},
					}
				},
				yAxis: [{
					type: 'value',

					axisLabel: {
						formatter: function(a) {
							a = +a;
							return isFinite(a) ?
								echarts.format.addCommas(+a / 1000) :
								'';
						},
						textStyle: {
							color: '#ffffff'
						}
					}
				}],
				series: [{
					name: '办结量',
					type: 'bar',
					barWidth: '60%',
					data: dataValue
				}]

			});


		}

	},
	error: function(errorMsg) {
		//请求失败时执行该函数
		console.log("图表请求数据失败!");
		//		myChart.hideLoading();
	}
})

//////////////////////交通流量 end

//各地市月累计办结量
var xAxisData = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
var data1 = [];
var data2 = [];
var data3 = [];
var data4 = [];
var dataListArray = [];
var dataName = [];
var dataValue2 = [];
var nth = [];
var seriesData = [];
$.ajax({
	type: "post",
	async: true, //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
	url: "http://218.60.150.112:8080/8890/api/interface/search/getBjCountByMonth.shtml", //请求的服务端地址
	data: {},
	dataType: "json", //返回数据形式为json
	success: function(data) {
		//请求成功时执行该函数内容，result即为服务器返回的json对象
		if (data) {
			var firstlei1 = data.各地市月累计办结量;
			for (var i = 0; i < firstlei1.length; i++) {
				for (var j = 0; j < firstlei1[i].length - 2; j++) {
					dataListArray.push({
						"name": firstlei1[i][j],
						"nth": firstlei1[i][j + 1],
						"value": firstlei1[i][j + 2]
					})
					dataName.push(
						firstlei1[i][j]
					)
					dataValue2.push(
						firstlei1[i][j + 2]
					)
					nth.push(
						firstlei1[i][j + 1] + "月份数据"
					)
				}

			}

			var myChart2 = echarts.init(document.getElementById('main2'));
			//app.title = '堆叠条形图';
			option2 = {
				color: ['#3398DB'],
				tooltip: {
					trigger: 'axis',
					axisPointer: {
						type: 'shadow',
						label: {
							show: true
						}
					},

				},
				tooltip: {
					enterable: true,
					trigger: 'axis',
					axisPointer: {
						type: 'shadow'
					},
					formatter: function(data) {
						var index = data[0].dataIndex;
						var relVal = dataName[index] + "<br/>";
						relVal += nth[index] + ' : ' + dataValue2[index] + "<br/>";
						return relVal;
					}
				},



				calculable: true,
				legend: {
					data: dataName,
					axisLabel: {
						inside: true,
						textStyle: {
							color: '#fff'
						}
					},
					axisTick: {
						show: false
					},
					axisLine: {
						show: false
					},
					z: 10,
					itemGap: 5,
					textStyle: {
						fontSize: 18,
						color: '#ffffff' //字体颜色
					},

				},
				grid: {
					top: '12%',
					left: '1%',
					right: '10%',
					containLabel: true
				},
				xAxis: [{
					type: 'category',
					data: dataName,
					axisLabel: {
						show: true,
						textStyle: {
							color: '#ffffff'
						}
					}

				}],
				yAxis: [{
					type: 'value',

					axisLabel: {
						formatter: function(a) {
							a = +a;
							return isFinite(a) ?
								echarts.format.addCommas(+a / 1000) :
								'';
						},
						textStyle: {
							color: '#ffffff'
						}
					}
				}],
				dataZoom: [{
						show: true,
						start: 130,
						end: 100
					},
					{
						type: 'inside',
						start: 130,
						end: 100
					}
				],
				series: [{
					name: dataName,
					type: 'bar',
					data: dataValue2

				}]

			};
			myChart2.setOption(option2);
		}
	},
	error: function(errorMsg) {
		//请求失败时执行该函数
		console.log("图表请求数据失败!");
		//		myChart.hideLoading();
	}
})

//本月发生事件1

var dataArrty = []; //类别数组
var ArrtyValue = [];
$.ajax({
	type: "post",
	async: true, //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
	url: "http://218.60.150.112:8080/8890/api/interface/search/getHotTop10.shtml", //请求的服务端地址
	data: {},
	dataType: "json", //返回数据形式为json
	success: function(data) {
		//请求成功时执行该函数内容，result即为服务器返回的json对象
		if (data) {
			var firstNo1 = data.热点问题排行前十.splice(0, 5);
			var firstNo5 = data.热点问题排行前十.splice(0, 5);
			for (var i = 0; i < firstNo1.length; i++) {
				for (var j = 0; j < firstNo1[i].length - 1; j++) {

					dataArrty.push({
						"name": firstNo1[i][j],
						"value": firstNo1[i][j + 1]
					})
					ArrtyValue.push(
						firstNo1[i][j + 1]
					)
				}

			}

			var ValueMax = ArrtyValue[0];

			var StringMax = ValueMax.toString();

			var DataMax = "";
			DataMaxFun(StringMax)
			 function DataMaxFun(data){
				var dataLength = data.length;
				var Max = data.slice(0,2);
				var MaxValue = "";
				// console.log(Max)
				if(Max[1]>5){
					var numMax = parseInt(Max[0])+1;
					MaxValue += numMax.toString()+0;

				}else{
					MaxValue += Max[0]
					var Num = parseInt(Max[1])
					MaxValue += Num+5
					
				}
				if(dataLength=6){
					return MaxValue+1000
				}else{
					return MaxValue+10000
				}
				
			}
			

			var DataMaxValue = DataMaxFun(StringMax);

			var myChart3 = echarts.init(document.getElementById('main3'));

			var data = dataArrty;

			myChart3.setOption({
				tooltip: {},
				legend: {

				},
				color: ['rgba(221,221,221,1)'],
				radar: {

					name: {
						textStyle: {
							color: '#fff',
							backgroundColor: '',
							borderRadius: 3,
							padding: [1, 1]
						}
					},

					indicator: [{
							name: dataArrty[0].name,
							max: DataMaxValue
						},
						{
							name: dataArrty[1].name,
							max: DataMaxValue
						},
						{
							name: dataArrty[2].name,
							max: DataMaxValue
						},
						{
							name: dataArrty[3].name,
							max: DataMaxValue
						},
						{
							name: dataArrty[4].name,
							max: DataMaxValue
						}
					],
					radius: 65
				},
				series: [{

					type: 'radar',
					data: [{
							value: [dataArrty[0].value, dataArrty[1].value, dataArrty[2].value, dataArrty[3].value, dataArrty[4].value],
							label: {
								normal: {
									show: true,
									formatter: function(params) {
										return params.value;
									}
								}
							}

						}

					]
				}]

			});

		}

	},
	error: function(errorMsg) {
		//请求失败时执行该函数
		console.log("图表请求数据失败!");
		//		myChart.hideLoading();
	}
})



//////////////////////本月发生事件1 end
//本月发生事件2
var ArrtyValue2 = [];
var dataArrty2 = []; //类别数组
$.ajax({
	type: "post",
	async: true, //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
	url: "http://218.60.150.112:8080/8890/api/interface/search/getHotTop10.shtml", //请求的服务端地址
	data: {},
	dataType: "json", //返回数据形式为json
	success: function(data) {
		//请求成功时执行该函数内容，result即为服务器返回的json对象
		if (data) {
			var firstNo1 = data.热点问题排行前十.splice(0, 5);
			var firstNo5 = data.热点问题排行前十.splice(0, 5);
			for (var i = 0; i < firstNo5.length; i++) {
				for (var j = 0; j < firstNo5[i].length - 1; j++) {

					dataArrty2.push({
						"name": firstNo5[i][j],
						"value": firstNo5[i][j + 1]
					})
					
				ArrtyValue2.push(
							firstNo5[i][j + 1]
						)
					}
				
				}
				
				var ValueMax = ArrtyValue2[0];
				// console.log(ValueMax)
				var StringMax = ValueMax.toString();
				var DataMax = "";
				DataMaxFun(StringMax)
				 function DataMaxFun(data){
					var dataLength = data.length;
					if(dataLength=5){
						var Max = parseInt(data.slice(0,1));
						if(Max>5){
							return Max+100000
						}else{
							return Max+60000
						}
					}else{
						var Max = data.slice(0,2);
						var MaxValue = "";
						// console.log(Max)
						if(Max[1]>5){
							var numMax = parseInt(Max[0])+1;
							MaxValue += numMax.toString()+0;
						}else{
							MaxValue += Max[0]
							var Num = parseInt(Max[1])
							MaxValue += Num+5
						}
						
						if(dataLength=6){
							return MaxValue+1000
						}else{
							return MaxValue+10000
						}
					}
	
				}
				
				var DataMaxValue2 = DataMaxFun(StringMax);
				console.log(DataMaxValue2)
			var myChart31 = echarts.init(document.getElementById('main31'));

			var data = dataArrty2;

			myChart31.setOption({
				tooltip: {},
				legend: {

				},
				color: ['rgba(221,221,221,1)'],
				radar: {
					// shape: 'circle',
					name: {
						textStyle: {
							color: '#fff',
							backgroundColor: '',
							borderRadius: 3,
							padding: [3, 5]
						}
					},
					indicator: [{
							name: dataArrty2[0].name,
							max: DataMaxValue2
						},
						{
							name: dataArrty2[1].name,
							max: DataMaxValue2
						},
						{
							name: dataArrty2[2].name,
							max: DataMaxValue2
						},
						{
							name: dataArrty2[3].name,
							max: DataMaxValue2
						},
						{
							name: dataArrty2[4].name,
							max: DataMaxValue2
						}

					],
					radius: 65
				},
				series: [{
					name: "",
					type: 'radar',
					// areaStyle: {normal: {}},
					data: [{
							value: [dataArrty2[0].value, dataArrty2[1].value, dataArrty2[2].value, dataArrty2[3].value, dataArrty2[4]
								.value
							],
							label: {
								normal: {
									show: true,
									formatter: function(params) {
										return params.value;
									}
								}
							}

						}

					]
				}]
			});


		}

	},
	error: function(errorMsg) {
		//请求失败时执行该函数
		console.log("图表请求数据失败!");
		//		myChart.hideLoading();
	}
})

//////////////////////本月发生事件2 end

//收费站收费排行1
//各地市月累计办结量
var xAxisData = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
var data1 = [];
var data2 = [];
var data3 = [];
var data4 = [];
var dataListArray = [];
var dataName = [];
var dataValue2 = [];
var nth = [];
var seriesData = [];
$.ajax({
	type: "post",
	async: true, //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
	url: "http://218.60.150.112:8080/8890/api/interface/search/getBlCountByMonth.shtml", //请求的服务端地址
	data: {},
	dataType: "json", //返回数据形式为json
	success: function(data) {
		//请求成功时执行该函数内容，result即为服务器返回的json对象
		if (data) {
			var firstlei1 = data.各地市月累计办理量;
			for (var i = 0; i < firstlei1.length; i++) {
				for (var j = 0; j < firstlei1[i].length - 2; j++) {
					dataListArray.push({
						"name": firstlei1[i][j],
						"nth": firstlei1[i][j + 1],
						"value": firstlei1[i][j + 2]
					})
					dataName.push(
						firstlei1[i][j]
					)
					dataValue2.push(
						firstlei1[i][j + 2]
					)
					nth.push(
						firstlei1[i][j + 1] + "月份数据",
					)
				}

			}




			var myChart4 = echarts.init(document.getElementById('main4'));
			//app.title = '堆叠条形图';
			myChart4.setOption({
				color: ['#3398DB'],
				tooltip: {
					trigger: 'axis',
					axisPointer: {
						type: 'shadow',
						label: {
							show: true
						}
					},
					formatter: function(params) {
						for (var key in this.dataName) {

							for (var key in this.nth) {

								return this.dataName[key] + "<br/>" + this.nth[key];

							}
						}
					}
				},


				tooltip: {
					enterable: true,
					trigger: 'axis',
					axisPointer: {
						type: 'shadow'
					},
					formatter: function(data) {

						var index = data[0].dataIndex;
						var relVal = dataName[index] + "<br/>";
						relVal += nth[index] + ' : ' + dataValue2[index] + "<br/>";
						return relVal;
					}
				},

				calculable: true,
				legend: {
					data: dataName,
					axisLabel: {
						inside: true,
						textStyle: {
							color: '#fff'
						}
					},
					axisTick: {
						show: false
					},
					axisLine: {
						show: false
					},
					z: 10,
					itemGap: 5,
					textStyle: {
						fontSize: 18, //字体大小
						color: '#ffffff' //字体颜色
					},

				},
				grid: {
					top: '12%',
					left: '1%',
					right: '10%',
					containLabel: true
				},
				xAxis: [{
					type: 'category',
					data: dataName,
					axisLabel: {
						show: true,
						textStyle: {
							color: '#ffffff'
						}
					}

				}],
				yAxis: [{
					type: 'value',

					axisLabel: {
						formatter: function(a) {
							a = +a;
							return isFinite(a) ?
								echarts.format.addCommas(+a / 1000) :
								'';
						},
						textStyle: {
							color: '#ffffff'
						}
					}
				}],
				dataZoom: [{
						show: true,
						start: 120,
						end: 100
					},
					{
						type: 'inside',
						start: 120,
						end: 100
					}
				],

				series: [{
					name: dataName,
					type: 'bar',
					data: dataValue2

				}]

			});
		}
	},
	error: function(errorMsg) {

		console.log("图表请求数据失败!");

	}
})
